﻿using System.Collections.Generic;
using System.Collections;

namespace ElevatorDispatching
{
    public abstract class GroupBase<T> : ICollection<T>
    {
        protected ICollection<T> Items { get; } = new SortedSet<T>();

        public virtual int Count => Items.Count;

        public virtual bool IsReadOnly => false;

        public virtual void Add(T item) => Items.Add(item);

        public virtual void Clear() => Items.Clear();

        public virtual bool Contains(T item) => Items.Contains(item);

        public virtual void CopyTo(T[] array, int arrayIndex) => Items.CopyTo(array, arrayIndex);

        public virtual IEnumerator<T> GetEnumerator() => Items.GetEnumerator();

        public bool Remove(T item) => Items.Remove(item);

        IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
    }
}
